<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>路由管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		function checkValidate()
		{

			var routerName=document.getElementById("routerName").value;

			var selectObj=document.getElementById("networkId");
			var networkId=selectObj.options[selectObj.selectedIndex].value;

			//判断是否为空
			if(routerName==null||routerName=="")
			{
				window.alertx("请输入路由名称！");
				return false;
			}
//			if(networkId==null||networkId=="")
//			{
//				window.alertx("请选择外部网络！");
//				return false;
//			}


		}
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
	</script>
</head>
<body>
<ul class="nav nav-tabs">

	<li><a href="${ctx}/scene/sceneRouter/">路由列表</a></li>
	<li class="active"><a href="${ctx}/scene/sceneRouter/form?id=${sceneRouter.id}"><c:choose ><c:when test="${type=='setGateWay'}">设置网关</c:when><c:otherwise>路由<shiro:hasPermission name="scene:sceneRouter:edit">${not empty sceneRouter.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="scene:sceneRouter:edit">查看</shiro:lacksPermission></c:otherwise></c:choose></a></li>
</ul><br/>
<form id="inputForm" modelAttribute="sceneRouter" action="${ctx}/scene/sceneRouter/save" method="post" class="form-horizontal">
	<input type="hidden" id="id" name="id" value="${sceneRouter.id}"/>
	<input type="hidden" id="type" name="type" value="${type}"/>
	<sys:message content="${message}"/>
	<%--<c:choose ><c:when test="${type=='setGateWay'}">true</c:when><c:otherwise>false</c:otherwise></c:choose>--%>
	<div class="control-group">
		<label class="control-label">路由名称：</label>
		<div class="controls">

			<input type="text" id="routerName" name="routerName" htmlEscape="false" maxlength="64" class="input-xlarge " <c:if test="${type=='setGateWay'}">readonly</c:if> value="${sceneRouter.routerName}"/>
			<%--<input id="routerName" htmlEscape="false" maxlength="64" class="input-xlarge" type="text" value="${type}"/>--%>
		</div>
	</div>
	<%--<c:if test="${type!='update'}">--%>
		<div class="control-group">
			<label class="control-label">外部网络：</label>
			<div class="controls">
				<select id="networkId" name="networkId" class="input-xlarge">
					<option value="" selected>====请选择====</option>
					<c:if test="${sceneNetwork!=null&&sceneNetwork!=''}">
						<option value="${sceneNetwork.id}">${sceneNetwork.networkName}</option>
					</c:if>


						<%--<c:forEach items="${sceneEnvironmentList}" var="sceneEnvironment">--%>
						<%--<option value="${sceneEnvironment.id}" <c:if test="${sceneEnvironment.id==resourceCourseware.environmentId}"> selected</c:if>>${sceneEnvironment.environmentName}</option>--%>
						<%--</c:forEach>--%>
				</select>
			</div>
		</div>
	<%--</c:if>--%>


	<div class="form-actions">
		<shiro:hasPermission name="scene:sceneRouter:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存" onclick=" return checkValidate()"/>&nbsp;</shiro:hasPermission>
		<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
	</div>
</form>
</body>
</html>